﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Practices.ServiceLocation;

namespace mForum.Core.Infrastructure.IoC
{
    using mForum.Core.Common;

    public static class IoC
    {
        private static IServiceLocator _locator;

        public static void InitializeWith(IServiceLocator locator)
        {
            Check.Argument.IsNotNull(locator, "locator");

            _locator = locator;
        }

        public static IEnumerable<TService> GetAllInstances<TService>()
        {
            return _locator.GetAllInstances<TService>();
        }

        public static IEnumerable<object> GetAllInstances(Type serviceType)
        {
            return _locator.GetAllInstances(serviceType);
        }

        public static TService GetInstance<TService>()
        {
            return _locator.GetInstance<TService>();
        }

        public static TService GetInstance<TService>(string key)
        {
            return _locator.GetInstance<TService>(key);
        }

        public static object GetInstance(Type serviceType)
        {
            return _locator.GetInstance(serviceType);
        }

        public static object GetInstance(Type serviceType, string key)
        {
            return _locator.GetInstance(serviceType, key);
        }
    }
}
